package com.qg.cyapp.activity;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.qg.cyapp.R;
import com.qg.cyapp.component.Dolly;

public class ShiYongYuEActivity extends Activity{

	private int i = Math.abs((int)System.currentTimeMillis() % 200);
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_yu_e);
		((TextView)findViewById(R.id.tv_ye_dizhi)).setText("当前账户余额为:" + i + "元，本次订餐将会扣除" + Dolly.getDolly().getTotalPrice() + "元");
		OnClickListener o = new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (R.id.bt_ye_queren == v.getId()) {
					if(i < Dolly.getDolly().getTotalPrice()) {
						Toast.makeText(ShiYongYuEActivity.this, "余额不足，订餐失败", Toast.LENGTH_LONG).show();
					} else {
						Toast.makeText(ShiYongYuEActivity.this, "订餐成功", Toast.LENGTH_LONG).show();
						Dolly.getDolly().destroyDolly();
						ShiYongYuEActivity.this.finish();
					}
				} else {
					ShiYongYuEActivity.this.finish();
				}
			}
		};
		findViewById(R.id.bt_ye_queren).setOnClickListener(o);
		findViewById(R.id.bt_ye_quxiao).setOnClickListener(o);
	
	}
	
}
